/*************************************************************************
	> File Name: p1036.cpp
	> Author: zhangxu 
	> Mail: walrus1983@126.com
	> Created Time: 五  8/30 13:36:16 2024
 ************************************************************************/

#include<iostream>
using namespace std;
#define MAX_N 20

int val[MAX_N + 5];
long long ans = 0;

bool isPrime(int x) {
	if(x == 2) return true;
	for(int i = 2; i * i <= x; i++) {
		if(x % i == 0) return false;
	}
	return true;
}

void dfs(int cnt, int min, int max, int m, int sum) {
	if(cnt == m) {
		if(isPrime(sum)) ans += 1;
		return ;
	}
	for(int i = min; i <= max; i++) {
		dfs(cnt + 1, i + 1, max, m, sum + val[i]);
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> val[i]; 
	}
	dfs(0, 1, n, m, 0);
	cout << ans << endl;
	return 0;
}